﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {

            string input = txtInput.Text;
            string day = "";
            // 使用 switch 结构进行多分支判断
            switch (input)
            {
                case "1":
                    day
        = "Monday";
                    break;
                case "2":
                    day
        = "Tuesday";
                    break;
                case "3":
                    day
        = "Wednesday";
                    break;
                case "4":
                    day
        = "Thursday";
                    break;
                case "5":
                    day
        = "Friday";
                    break;
                case "6":
                    day
        = "Saturday";
                    break;
                case "7":
                    day
        = "Sunday";
                    break;
                default:
                    // 输入不是 1 - 7 时弹出提示框
                    MessageBox
        .Show("请输入数字 1 - 7！");
                    // 清空输入和结果文本框
                    txtInput
        .Clear();
                    txtResult
        .Clear();
                    // 将焦点设置到输入文本框
                    txtInput
        .Focus();
                    return;
            }
            // 显示对应的星期
            txtResult
        .Text = day;
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            // 清空两个文本框的内容
            txtInput
        .Clear();
            txtResult
        .Clear();
            // 将焦点设置到输入文本框
            txtInput
        .Focus();
        }
    }
}
